<template>
  <div>
    <ul class="news-list-items" v-if="items && items.length > 0">
      <li class="news-list-item" v-for="(item, index) in items" :key="index">
        <a-card shadow="hover">
          <router-link :to="`/articles/detail/${item.id}`">
            <img :src="getFile(item.coverImg)" alt="">
            <div class="item-content">
              <div class="title">{{ item.title }}</div>
              <p>{{ item.remark }}</p>
              <span>{{ item.publishTime }}</span>
            </div>
          </router-link>
        </a-card>
      </li>
    </ul>
    <EmptyData  v-else>暂无数据</EmptyData>
  </div>
</template>
<script lang="ts" setup>
import { PropType } from "vue";
import EmptyData from "@/components/public/EmptyData.vue";

const props = defineProps({
  items: {
    type: Array as PropType<Array<any>>,
    default: () => ([])
  }
});

</script>
<style lang="less" scoped>
.news-list-item {
  padding: 0 15px 15px 8px;
  position: relative;
  border-radius: 8px;

  img {
    width: 198px;
    height: 100px;
    border-style: none;
  }

  a {
    color: rgba(0, 0, 0, 1);
    transition: color .3s;
    overflow: hidden;
    display: flex;
    cursor: pointer;
  }

  a:hover {
    color: var(--hover_color);
  }
}

.item-mask {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0);
  transition: all .3s;
  border-radius: 8px;
}

.item-content {
  margin-left: 40px;
  width: calc(100% - 238px);

  .title {
    font-size: 16px;
    font-weight: 500;
    overflow: hidden;
    //white-space: nowrap;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  p {
    margin: 10px 0;
    font-size: 14px;
    color: #777;
    letter-spacing: 0;
    line-height: 22px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
  }

  span {
    color: #b8b8b8;
    line-height: 13px;
  }
}
</style>
